<template>
	<view class="back-view" @touchmove.stop.prevent="moveHandle">
		<view class="view-background"></view>
		<view class="white-view-back">
			<view class="top-back">
				<view class="top-name">承办律师</view>
				<view class="close-back" @click="closeBtnAction">
					<image class="close-img" src="../../../static/close.png"></image>
				</view>
			</view>

			<view class="header-back">
				<image class="header-img" :src="customerItem.account.avatarPic"></image>
				<view class="header-name">{{customerItem.account.realName}}</view>
			</view>
			<view class="select-back-back">
				<view class="center-select-back" @click="clickSelectOne">
					<view :class="select == 0?'celter-select':'celter-unselect'">律师介绍</view>
					<view :class="select == 0?'celter-select-line':'celter-unselect-line'"></view>
				</view>
				<view class="center-select-back" @click="clickSelectTwo" v-if="role != '0'">
					<view :class="select == 1?'celter-select':'celter-unselect'">联系方式</view>
					<view :class="select == 1?'celter-select-line':'celter-unselect-line'"></view>
				</view>
			</view>
			<scroll-view class="content-view" scroll-y="true">
				<view v-if="select == 0" style="padding: 10px;">
					<rich-text v-if="introduceText !== '<p><br></p>'" :nodes="introduceText"> </rich-text>
				</view>

				<view v-if="select == 1" style="padding: 20px;">
					<view class="item-back">
						<view class="item-name">律师姓名:</view>
						<view class="item-content">{{customerItem.account.realName}}</view>
					</view>
					<view class="item-back">
						<view class="item-name">联系电话:</view>
						<view class="item-content">{{customerItem.account.mobile}}</view>
					</view>
					<view class="item-back">
						<view class="item-name">微信号:</view>
						<view class="item-content">{{customerItem.account.wxNo}}</view>
					</view>
					<view class="item-back">
						<view class="item-name">邮箱:</view>
						<view class="item-content">{{customerItem.account.email}}</view>
					</view>
				</view>
			</scroll-view>

		</view>
	</view>
</template>

<script>
	let app = ''
	export default {
		props: {
			lawyerID: {
				type: String,
				default: ''
			},
		},
		data() {
			return {
				select: 0,
				role: '', //当前登录角色
				roleUrl: '',
				introduceText: '', // 活动介绍的富文本内容
				customerItem:{}
			}
		},
		mounted() {
			var _this = this;
			app = getApp()
			_this.role = app.globalData.role
			_this.roleUrl = _this.$roleUrl({
				tab: _this.role
			})
			this.getCaseUserLawyers();
		},
		methods: {

			/**
			 * 承办律师
			 */
			async getCaseUserLawyers() {
				let _this = this
				var parms = {
					'id': this.lawyerID,	
				}
				const res = await _this.$myRequest({
					url: `/${_this.roleUrl}/lawyer/selector`,
					method: 'POST',
					data: parms
				})
				// console.log('承办律师',res)
				if (res.data.code == 200) {
					console.log(res)
					_this.customerItem = res.data.data[0];
					_this.introduceText = _this.richText(_this.customerItem.remark);
					
				}
			},
			closeBtnAction() {
				this.$emit('clickLawInfoClose')
			},
			moveHandle() {
				return true
			},
			clickSelectOne() {
				this.select = 0;
			},
			clickSelectTwo() {
				this.select = 1;
			},
			// 解析富文本后显示数据
			richText(richTextData) {
				if (richTextData) {
					var richtext = richTextData;
					const regex = new RegExp('<img', 'gi');
					const regex2 = new RegExp('src="/api', 'gi');
					richtext = richtext.replace(regex2, `src="${this.$ServerBaseUrl}/api`);
					richtext = richtext.replace(regex, `<img style="max-width: 100%;"`);
					return richtext;
				} else {
					return '';
				}
			},
		},
	}
</script>

<style>
	.back-view {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 999;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.view-background {
		position: absolute;
		width: 100%;
		height: 100%;
		z-index: 1000;
		background-color: rgba(0, 0, 0, 0.3);
	}

	.white-view-back {
		width: 600px;
		height: 540px;
		padding: 24px;
		max-height: 540px;
		background-color: white;
		margin-top: -50px;
		border-radius: 4px;
		z-index: 10001;
		position: absolute;
	}

	.top-back {
		display: flex;
		justify-content: space-between;
	}

	.top-name {
		font-size: 18px;
		font-weight: normal;
		color: #333333;

	}

	.close-back {
		cursor: pointer;
		width: 20px;
		height: 20px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.close-img {
		width: 12px;
		height: 12px;
	}

	.header-back {
		margin-top: 24px;
		width: 100%;
		height: 180px;
		background-color: #777;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}

	.header-img {
		width: 64px;
		height: 64px;
		border: 2px solid #EEEEEE;
		border-radius: 50%;
	}

	.header-name {
		font-size: 18px;
		font-weight: 600;
		color: #FFFFFF;
		margin-top: 10px;
	}

	.select-back-back {
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
	}

	.center-select-back {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		height: 44px;
		margin-left: 36px;
		margin-right: 36px;
	}

	.celter-unselect {
		font-size: 16px;

		font-weight: 400;
		color: #999999;
	}

	.celter-select {
		font-size: 16px;

		font-weight: 400;
		color: #333333;
	}

	.celter-select-line {
		width: 40px;
		height: 2px;
		background: #2DA9C5;
	}

	.celter-unselect-line {
		width: 40px;
		height: 2px;
	}

	.content-view {
		width: 100%;
		height: 240px;
		background-color: #eee;
		margin-top: 10px;
	}

	.item-back {
		display: flex;
		align-items: center;
		margin-bottom: 10px;
	}

	.item-name {
		width: 70px;
		font-size: 14px;
		font-weight: 400;
		color: #999999;
	}

	.item-content {
		font-size: 14px;
		font-weight: 400;
		color: #333333;
	}
</style>
